<template>
  <div class='container'>
    <el-dialog
      title="题目审核"
      :visible.sync="showDialogCK"
      :before-close="close"
      width="40%"
    >
      <el-radio
        v-model="checkData.chkState"
        label="1"
      >通过</el-radio>
      <el-radio
        v-model="checkData.chkState"
        label="2"
      >拒绝</el-radio>
      <el-row>
        <el-input
          v-model="checkData.chkRemarks"
          type="textarea"
          placeholder="请输入审核意见"
          :rows="3"
          style="margin-top:20px"
        ></el-input>
      </el-row>
      <!-- footer插槽 -->
      <template v-slot:footer>
        <el-row
          type="flex"
          justify="end"
        >

          <el-button
            size="small"
            @click="$emit('close')"
          >取消</el-button>
          <el-button
            type="primary"
            size="small"
            @click="btnOK"
          >确定</el-button>

        </el-row>
      </template>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  props: {
    showDialogCK: {
      type: Boolean,
      required: true
    },
    questionItem: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      checkData: {
        chkState: '1', // 通过 2 不通过
        chkRemarks: ''// 审核备注
      }
    }
  },
  methods: {
    // 审核意见
    async btnOK () {
      if (this.checkData.chkRemarks.length === 0) {
        return this.$message.warning('请输入审核意见')
      }
      // 得到的数据
      const data = await choiceCheck({
        id: this.questionItem.id,
        chkState: +this.checkData.chkState,
        chkRemarks: this.checkData.chkRemarks
      })
      console.log(data)
      this.$emit('close')
      this.$message.success('审核成功')
    },
    close () {
      this.$emit('close')
      this.checkData.chkRemarks = ''
    }

  }
}
</script>

<style scoped lang='scss'></style>
